package com.wyzz.hr.bo.impl;

import java.text.SimpleDateFormat;
import java.util.*;
import org.hibernate.FetchMode;
import org.hibernate.criterion.*;

import com.wyzz.hr.bo.IAttendshiftBO;
import com.wyzz.hr.bo.IEmpshiftBo;
import com.wyzz.hr.bo.ILeavecalendarBO;
import com.wyzz.hr.dao.IEmpshiftDAO;
import com.wyzz.hr.dao.ILeavecalendarDAO;
import com.wyzz.hr.pojo.Attendshift;
import com.wyzz.hr.pojo.Attendshiftareadept;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Empshift;
import com.wyzz.hr.pojo.Leavecalendar;
import com.wyzz.hr.pojo.Leaverequest;
import com.wyzz.hr.pojo.Overtimerequest;
import com.wyzz.hr.spring.SpringBeanFactory;
import com.wyzz.hr.util.BaseCrit;
import com.wyzz.hr.util.DateUtil;
import com.wyzz.hr.util.StringUtil;

public class EmpshiftBOImpl implements IEmpshiftBo {

	public EmpshiftBOImpl() {
	}

	public boolean addEmpshift(Empshift empshift) {
		empshiftDAO.saveObject(empshift);
		return true;
	}

	public boolean deleteEmpshift(Empshift empshift) {
		empshiftDAO.deleteObject(empshift);
		return true;
	}

	public Empshift getEmpshift(String id) {
		empshiftDAO.loadObject(com.wyzz.hr.pojo.Empshift.class, id, null,
				new boolean[0]);
		return null;
	}

	public boolean updateEmpshift(Empshift empshift) {
		empshiftDAO.saveOrupdate(empshift);
		return false;
	}

	public boolean batchSaveEmpshift(List empshiftList, List deleteList) {
		if (deleteList.size() > 0) {
			String shiftIdStr = "";
			for (Iterator i$ = deleteList.iterator(); i$.hasNext();) {
				Empshift empshift = (Empshift) i$.next();
				shiftIdStr = (new StringBuilder()).append(shiftIdStr).append(
						"'").append(empshift.getId()).append("',").toString();
			}

			shiftIdStr = shiftIdStr.substring(0, shiftIdStr.length() - 1);
			String hql = (new StringBuilder()).append(
					"delete from Empshift where id in (").append(shiftIdStr)
					.append(")").toString();
			empshiftDAO.exeHql(hql);
		}
		empshiftDAO.saveOrupdate(empshiftList);
		return true;
	}

	public Attendshift getEmpShiftByDate(Date shiftDate, Employee emp) {
		shiftDate = DateUtil.convDateTimeToDate(shiftDate);
		Attendshift as = null;
		if (emp.getEmpShiftType().intValue() == 3) {
			List list = getEmpShiftList(shiftDate, shiftDate, emp.getId());
			if (list == null || list.isEmpty())
				return null;
			as = ((Empshift) list.get(0)).getEmpshiftShiftNo();
		} else {
			ILeavecalendarBO lcBO = (ILeavecalendarBO) SpringBeanFactory
					.getBean("leavecalendarBO");
			List lcList = lcBO.getCalendarListByDay(shiftDate, shiftDate);
			int holidayFlag = lcBO.isACalendarDay(shiftDate, lcList, emp
					.getEmpLocationNo());
			if (holidayFlag == 0 || holidayFlag == 2)
				return null;
			IAttendshiftBO attendshiftBo = (IAttendshiftBO) SpringBeanFactory
					.getBean("attendshiftBO");
			as = attendshiftBo.getDefaultAttendshiftByEmp(emp);
		}
		return as;
	}

	public List getEmpShiftList(Date startDate, Date endDate, String empId) {
		DetachedCriteria dc = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empshift.class);
		startDate = DateUtil.convDateTimeToDate(startDate);
		endDate = DateUtil.convDateTimeToDate(endDate);
		dc.setFetchMode(Empshift.PROP_EMPSHIFT_SHIFT_NO, FetchMode.JOIN);
		dc.add(Restrictions.eq(Empshift.PROP_EMPSHIFT_EMP_NO, new Employee(
				empId)));
		dc.add(Restrictions.ge(Empshift.PROP_EMPSHIFT_DATE, startDate));
		dc.add(Restrictions.le(Empshift.PROP_EMPSHIFT_DATE, endDate));
		dc.addOrder(Order.asc(Empshift.PROP_EMPSHIFT_DATE));
		return empshiftDAO.findByCriteria(dc);
	}

	public HashMap getEmpshiftList(String empIds[], Date allDays[]) {
		DetachedCriteria dc = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empshift.class);
		dc.setFetchMode(Empshift.PROP_EMPSHIFT_SHIFT_NO, FetchMode.JOIN);
		dc.add(Restrictions.in("empshiftEmpNo.id", empIds));
		dc.add(Restrictions.in(Empshift.PROP_EMPSHIFT_DATE, allDays));
		List empshiftList = empshiftDAO.findByCriteria(dc);
		HashMap map = new HashMap();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Empshift empshift;
		for (Iterator i$ = empshiftList.iterator(); i$.hasNext(); map.put(
				(new StringBuilder()).append(
						empshift.getEmpshiftEmpNo().getId()).append(
						format.format(empshift.getEmpshiftDate())).toString(),
				empshift))
			empshift = (Empshift) i$.next();

		return map;
	}

	public HashMap getEmpshiftList(String empIds[], Date startDate, Date endDate) {
		DetachedCriteria dc = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empshift.class);
		dc.setFetchMode(Empshift.PROP_EMPSHIFT_SHIFT_NO, FetchMode.JOIN);
		dc.add(Restrictions.in("empshiftEmpNo.id", empIds));
		dc.add(Restrictions.ge(Empshift.PROP_EMPSHIFT_DATE, startDate));
		dc.add(Restrictions.le(Empshift.PROP_EMPSHIFT_DATE, endDate));
		List empshiftList = empshiftDAO.findByCriteria(dc);
		HashMap map = new HashMap();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Empshift empshift;
		for (Iterator i$ = empshiftList.iterator(); i$.hasNext(); map.put(
				(new StringBuilder()).append(
						empshift.getEmpshiftEmpNo().getId()).append(
						format.format(empshift.getEmpshiftDate())).toString(),
				empshift))
			empshift = (Empshift) i$.next();

		return map;
	}

	public Map provideEmpShiftData(String empIds[], Date start, Date end) {
		if (empIds == null || empIds.length == 0)
			return new HashMap(0);
		DetachedCriteria dc = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empshift.class);
		dc.setFetchMode(Empshift.PROP_EMPSHIFT_SHIFT_NO, FetchMode.JOIN);
		BaseCrit.addDCDateRange(dc, Empshift.PROP_EMPSHIFT_DATE, start, end);
		if (empIds.length < 500)
			dc.add(Restrictions.in("empshiftEmpNo.id", empIds));
		List empShiftList = empshiftDAO.findByCriteria(dc);
		Map resultMap = new HashMap();
		Empshift empShift;
		String key;
		try {
			for (Iterator i$ = empShiftList.iterator(); i$.hasNext(); resultMap
					.put(key, empShift.getEmpshiftShiftNo().clone())) {
				empShift = (Empshift) i$.next();
				key = (new StringBuilder()).append(
						empShift.getEmpshiftEmpNo().getId()).append(
						DateUtil.formatDate(empShift.getEmpshiftDate()))
						.toString();
			}
		} catch (CloneNotSupportedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return resultMap;
	}

	public Integer isInWorkShift(Date examinCheckDate, List list) {
		int inShift;
		label0: {
			inShift = 0;
			if (list == null || list.size() < 1)
				break label0;
			Iterator empShiftIterator = list.iterator();
			do {
				if (!empShiftIterator.hasNext())
					break label0;
				Empshift es = (Empshift) empShiftIterator.next();
				inShift = ExaminDateUtil.isTimeInShift(examinCheckDate, es
						.getEmpshiftDate(), es.getEmpshiftShiftNo()
						.getAttsSession());
			} while (inShift == 0);
			return Integer.valueOf(inShift);
		}
		return Integer.valueOf(inShift);
	}

	public int computeTotalLeaveMinutes(Date startDate, Date endDate, List list) {
		int minuteInShift = 0;
		if (list != null && list.size() >= 1) {
			Iterator empShiftIterator = list.iterator();
			do {
				if (!empShiftIterator.hasNext())
					break;
				Empshift es = (Empshift) empShiftIterator.next();
				int i = DateUtil.dateDiff(startDate, es.getEmpshiftDate(), 5);
				int j = DateUtil.dateDiff(endDate, es.getEmpshiftDate(), 5);
				if (i >= -1 && j <= 0)
					if ((i == -1 || j == -1)
							&& es.getEmpshiftShiftNo().getAttsNightShift()
									.intValue() == 1 || i == 0 || j == 0) {
						minuteInShift += ExaminDateUtil.minutesInShift(
								startDate, endDate, es.getEmpshiftDate(), es
										.getEmpshiftShiftNo().getAttsSession());
					} else {
						double minute = es.getEmpshiftShiftNo()
								.getAttsWorkingHour().doubleValue() * 60D;
						minuteInShift = (int) ((double) minuteInShift + minute);
					}
			} while (true);
		}
		return minuteInShift;
	}

	public List validateShift(List empShiftList, Map oldShiftMap) {
		List errorList = new ArrayList();
		if (empShiftList.isEmpty())
			return errorList;
		TreeSet dateSet = new TreeSet();
		Set empSet = new HashSet();
		Empshift empShift;
		for (Iterator i$ = empShiftList.iterator(); i$.hasNext(); empSet
				.add(empShift.getEmpshiftEmpNo().getId())) {
			empShift = (Empshift) i$.next();
			dateSet.add(empShift.getEmpshiftDate());
		}

		List leaveRequestList = getEmpLeaveRequestList((Date) dateSet.first(),
				(Date) dateSet.last(), empSet);
		List overtimeRequest = getEmpOvertimeRequestList(
				(Date) dateSet.first(), (Date) dateSet.last(), empSet);
		ExaminDateUtil examinDateUtil = ExaminDateUtil.getInstance();
		for (Iterator i$ = empShiftList.iterator(); i$.hasNext();) {
			empShift = (Empshift) i$.next();
			Date shiftDate = empShift.getEmpshiftDate();
			String key = (new StringBuilder()).append(
					empShift.getEmpshiftEmpNo().getId()).append(
					DateUtil.formatDate(shiftDate)).toString();
			Attendshift oldShift = oldShiftMap.get(key) != null ? ((Empshift) oldShiftMap
					.get(key)).getEmpshiftShiftNo()
					: null;
			Attendshift newShift = empShift.getEmpshiftShiftNo();
			if ((newShift != null || oldShift != null)
					&& (newShift == null || oldShift == null || !newShift
							.getId().equals(oldShift.getId()))) {
				i$ = leaveRequestList.iterator();
				do {
					if (!i$.hasNext())
						break;
					Leaverequest lr = (Leaverequest) i$.next();
					if (empShift.getEmpshiftEmpNo().getId().equals(
							lr.getLrEmpNo().getId()))
						if (oldShift != null) {
							ExaminDateUtil _tmp = examinDateUtil;
							int todayLrTotal = ExaminDateUtil.minutesInShift(lr
									.getLrStartDate(), lr.getLrEndDate(),
									shiftDate, oldShift.getAttsSession());
							if (todayLrTotal > 0)
								errorList
										.add((new StringBuilder())
												.append(
														lr.getLrEmpNo()
																.getEmpName())
												.append(
														DateUtil
																.formatDate(shiftDate))
												.append(oldShift.getAttsName())
												.append(
														"\u6709\u8BF7\u5047(\u7F16\u53F7\u4E3A")
												.append(lr.getLrNo()).append(
														")\uFF01").toString());
						} else if (shiftDate.compareTo(lr.getLrStartDate()) >= 0
								&& shiftDate.compareTo(lr.getLrEndDate()) <= 0)
							errorList.add((new StringBuilder()).append(
									lr.getLrEmpNo().getEmpName()).append(
									DateUtil.formatDate(shiftDate)).append(
									newShift.getAttsName()).append(
									"\u6709\u8BF7\u5047(\u7F16\u53F7\u4E3A")
									.append(lr.getLrNo()).append(")\uFF01")
									.toString());
				} while (true);
				if (newShift != null) {
					i$ = overtimeRequest.iterator();
					while (i$.hasNext()) {
						Overtimerequest or = (Overtimerequest) i$.next();
						if (empShift.getEmpshiftEmpNo().getId().equals(
								or.getOrEmpNo().getId())) {
							ExaminDateUtil _tmp1 = examinDateUtil;
							int todayOrTotal = ExaminDateUtil.minutesInShift(or
									.getOrStartDate(), or.getOrEndDate(),
									shiftDate, newShift.getAttsSession());
							if (todayOrTotal > 0)
								errorList
										.add((new StringBuilder())
												.append(
														or.getOrEmpNo()
																.getEmpName())
												.append(
														DateUtil
																.formatDate(shiftDate))
												.append(newShift.getAttsName())
												.append(
														"\u4E0E\u52A0\u73ED\u51B2\u7A81(\u7F16\u53F7\u4E3A")
												.append(or.getOrNo()).append(
														")\uFF01").toString());
							else if (newShift.getAttsNightShift().intValue() == 1) {
								Date nextDay = DateUtil.dateAdd(shiftDate, 1);
								ExaminDateUtil _tmp2 = examinDateUtil;
								int nextDayTotal = ExaminDateUtil
										.minutesInShift(or.getOrStartDate(), or
												.getOrEndDate(), nextDay,
												newShift.getAttsSession());
								if (nextDayTotal > 0)
									errorList
											.add((new StringBuilder())
													.append(
															or
																	.getOrEmpNo()
																	.getEmpName())
													.append(
															DateUtil
																	.formatDate(nextDay))
													.append(
															newShift
																	.getAttsName())
													.append(
															"\u4E0E\u52A0\u73ED\u51B2\u7A81(\u7F16\u53F7\u4E3A")
													.append(or.getOrNo())
													.append(")\uFF01")
													.toString());
							}
						}
					}
				}
			}
		}

		return errorList;
	}

	private List getEmpOvertimeRequestList(Date startDate, Date endDate,
			Set emps) {
		Calendar toDate = Calendar.getInstance();
		toDate.setTime(endDate);
		toDate.add(5, 1);
		DetachedCriteria detachedCrteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Overtimerequest.class);
		detachedCrteria.setFetchMode(Overtimerequest.PROP_OR_EMP_NO,
				FetchMode.JOIN);
		detachedCrteria.add(Restrictions.or(Restrictions.and(Restrictions.ge(
				"orStartDate", startDate), Restrictions.lt("orStartDate",
				toDate.getTime())), Restrictions.and(Restrictions.lt(
				"orEndDate", toDate.getTime()), Restrictions.ge("orEndDate",
				startDate))));
		detachedCrteria.add(Restrictions.not(Restrictions.in(
				Overtimerequest.PROP_OR_STATUS, new Integer[] {
						Integer.valueOf(21), Integer.valueOf(22) })));
		detachedCrteria.add(Restrictions.in("orEmpNo.id", emps));
		return empshiftDAO.findByCriteria(detachedCrteria);
	}

	private List getEmpLeaveRequestList(Date startDate, Date endDate, Set emps) {
		Calendar toDate = Calendar.getInstance();
		toDate.setTime(endDate);
		toDate.add(5, 1);
		DetachedCriteria detachedCrteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Leaverequest.class);
		detachedCrteria.setFetchMode(Leaverequest.PROP_LR_EMP_NO,
				FetchMode.JOIN);
		detachedCrteria.add(Restrictions.or(Restrictions.or(Restrictions.and(
				Restrictions.ge(Leaverequest.PROP_LR_START_DATE, startDate),
				Restrictions.lt(Leaverequest.PROP_LR_START_DATE, toDate
						.getTime())), Restrictions.and(Restrictions.lt(
				Leaverequest.PROP_LR_END_DATE, toDate.getTime()), Restrictions
				.ge(Leaverequest.PROP_LR_END_DATE, startDate))), Restrictions
				.and(Restrictions
						.lt(Leaverequest.PROP_LR_START_DATE, startDate),
						Restrictions.ge(Leaverequest.PROP_LR_END_DATE, toDate
								.getTime()))));
		detachedCrteria.add(Restrictions.not(Restrictions.in(
				Leaverequest.PROP_LR_STATUS, new Integer[] {
						Integer.valueOf(21), Integer.valueOf(22) })));
		detachedCrteria.add(Restrictions.in("lrEmpNo.id", emps));
		return empshiftDAO.findByCriteria(detachedCrteria);
	}

	public IEmpshiftDAO getEmpshiftDAO() {
		return empshiftDAO;
	}

	public void setEmpshiftDAO(IEmpshiftDAO empshiftDAO) {
		this.empshiftDAO = empshiftDAO;
	}

	private Map getAllRelationShift() {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Attendshiftareadept.class);
		detachedCriteria.createAlias("asadShiftId", "shift", 1);
		detachedCriteria.add(Restrictions
				.eq("shift.attsStatus", new Integer(1)));
		List relaList = empshiftDAO.findByCriteria(detachedCriteria);
		Map map = new HashMap();
		Set tempSet = null;
		String key = null;
		Attendshiftareadept asad;
		for (Iterator i$ = relaList.iterator(); i$.hasNext(); tempSet.add(asad
				.getAsadShiftId().getId())) {
			asad = (Attendshiftareadept) i$.next();
			key = asad.getAsadAreaId() == null ? asad.getAsadDeptId().getId()
					: asad.getAsadAreaId().getId();
			tempSet = (Set) map.get(key);
			if (map.get(key) == null) {
				tempSet = new HashSet();
				map.put(key, tempSet);
			}
		}

		return map;
	}

	private Map getEmpMapByIds(String Ids[]) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Employee.class);
		detachedCriteria.add(Restrictions.in("id", Ids));
		List empList = empshiftDAO.findByCriteria(detachedCriteria);
		Map empMap = new HashMap();
		Employee emp;
		for (Iterator i$ = empList.iterator(); i$.hasNext(); empMap.put(emp
				.getId(), emp))
			emp = (Employee) i$.next();

		return empMap;
	}

	private List getNonStrictShift() {
		String hql = "select id from Attendshift where attsStatus=1 and  attsStricked=0";
		List shiftIdList = empshiftDAO.exeHqlList(hql);
		return shiftIdList;
	}

	public void checkShiftSchedule(List errorList, String empIds[],
			List empshiftList) {
		if (empshiftList == null || empshiftList.size() == 0)
			return;
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Map empMap = getEmpMapByIds(empIds);
		List nonStrictShift = getNonStrictShift();
		Map relationShift = getAllRelationShift();
		Employee emp = null;
		String shiftId = null;
		Set locShifts = null;
		Set deptShifts = null;
		String error = null;
		Iterator i$ = empshiftList.iterator();
		do {
			if (!i$.hasNext())
				break;
			Empshift empshift = (Empshift) i$.next();
			emp = (Employee) empMap.get(empshift.getEmpshiftEmpNo().getId());
			if (empshift.getEmpshiftShiftNo() != null) {
				shiftId = empshift.getEmpshiftShiftNo().getId();
				if (!nonStrictShift.contains(shiftId)) {
					locShifts = (Set) relationShift.get(emp.getEmpLocationNo()
							.getId());
					deptShifts = (Set) relationShift.get(emp.getEmpDeptNo()
							.getId());
					if ((locShifts == null || !locShifts.contains(shiftId))
							&& (deptShifts == null || !deptShifts
									.contains(shiftId))) {
						error = (new StringBuilder())
								.append(emp.getEmpName())
								.append(" ")
								.append(
										format.format(empshift
												.getEmpshiftDate()))
								.append(" ")
								.append(
										empshift.getEmpshiftShiftNo()
												.getAttsShortName())
								.append(
										" \u6392\u73ED\u51FA\u9519\uFF1A\u8BE5\u5458\u5DE5\u4E0D\u53EF\u4EE5\u6392\u8BE5\u73ED\u6B21\uFF01")
								.toString();
						errorList.add(error);
					}
				}
			}
		} while (true);
	}

	public Attendshift changeAttdSessionWithOR(Date examinDate,
			Attendshift shift, List orList) {
		if (orList == null || orList.size() == 0)
			return shift;
		for (int i = 0; i < orList.size(); i++) {
			Overtimerequest or = (Overtimerequest) orList.get(i);
			String startTime = DateUtil.formatDateToS(or.getOrStartDate(),
					"yyyy-MM-dd HH:mm").substring(11);
			String endTime = DateUtil.formatDateToS(or.getOrEndDate(),
					"yyyy-MM-dd HH:mm").substring(11);
			if (DateUtil.convDateTimeToDate(or.getOrStartDate()).getTime() != examinDate
					.getTime())
				startTime = (new StringBuilder()).append(
						Integer.parseInt(startTime.split(":")[0]) + 24).append(
						":").append(startTime.split(":")[1]).toString();
			if (DateUtil.convDateTimeToDate(or.getOrEndDate()).getTime() != examinDate
					.getTime())
				endTime = (new StringBuilder()).append(
						Integer.parseInt(endTime.split(":")[0]) + 24).append(
						":").append(endTime.split(":")[1]).toString();
			String currentCut = (new StringBuilder()).append(startTime).append(
					"-").append(endTime).toString();
			String newAttdSession = StringUtil.addSegmentToShift(shift
					.getNewAttdSession(), currentCut);
			shift.setNewAttdSession(newAttdSession);
		}

		String newAttdSessionArr[] = shift.getNewAttdSession().split(",|-");
		Integer nightShift = Integer.valueOf(0);
		int i = 0;
		do {
			if (i >= newAttdSessionArr.length)
				break;
			if (Integer.parseInt(newAttdSessionArr[i].split(":")[0]) >= 24) {
				nightShift = Integer.valueOf(1);
				break;
			}
			i++;
		} while (true);
		shift.setNewAttdNightShift(nightShift);
		return shift;
	}

	public void provideDefaultShift(Map empShiftMap, Date start, Date end,
			List empList) {
		ILeavecalendarDAO dao = (ILeavecalendarDAO) SpringBeanFactory
				.getBean("leavecalendarDAO");
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Leavecalendar.class);
		detachedCriteria.add(Restrictions.ge("lcDate", start));
		detachedCriteria.add(Restrictions.le("lcDate", end));
		List leList = dao.findByCriteria(detachedCriteria);
		IAttendshiftBO attendshiftBo = (IAttendshiftBO) SpringBeanFactory
				.getBean("attendshiftBO");
		List asadList = attendshiftBo.searchDefaultAttendShiftRela();
		Attendshift nonStrictDefaultShift = attendshiftBo
				.getNonStrictDefaultAttendshift();
		Calendar calendar = Calendar.getInstance();
		Date compareObj = (Date) start.clone();
		boolean needShift = false;
		boolean inLeaveCalendar = false;
		do {
			if (compareObj.compareTo(end) > 0)
				break;
			calendar.setTime(compareObj);
			inLeaveCalendar = false;
			needShift = false;
			Iterator i$ = leList.iterator();
			do {
				if (!i$.hasNext())
					break;
				Leavecalendar leavecalendar = (Leavecalendar) i$.next();
				if (!leavecalendar.getLcDate().equals(compareObj))
					continue;
				inLeaveCalendar = true;
				if (leavecalendar.getLcSign().intValue() != 1)
					continue;
				needShift = true;
				break;
			} while (true);
			if (!inLeaveCalendar && calendar.get(7) != 7
					&& calendar.get(7) != 1)
				needShift = true;
			if (!needShift) {
				calendar.add(5, 1);
				compareObj = calendar.getTime();
			} else {
				i$ = empList.iterator();
				do {
					if (!i$.hasNext())
						break;
					Employee emp = (Employee) i$.next();
					if (emp.getEmpShiftType().intValue() != 3) {
						Attendshift defaultShift = attendshiftBo
								.getDefaultAttendshiftByEmp(asadList,
										nonStrictDefaultShift, emp);
						String key = (new StringBuilder()).append(emp.getId())
								.append(DateUtil.formatDate(compareObj))
								.toString();
						empShiftMap.put(key, defaultShift);
					}
				} while (true);
				calendar.add(5, 1);
				compareObj = calendar.getTime();
			}
		} while (true);
	}

	private IEmpshiftDAO empshiftDAO;
}
